<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>菜鸟教程(runoob.com)</title>
    <script src="../js/vue.min.js"></script>
</head>
<body>
<div id="app">
    <ul>
        <li v-for="(todo,index) in todos" >
            <!--(value, index) in arr-->
            <!--:ref=为动态绑定-->
            <!--无track-by情况：数据修改时，无论值是否被修改，dom都被重新渲染（控制台可以看到）-->
            <!--加入track-by属性：数据修改时-->
            <!--在2.0中被:key代替-->
            <span ref="aa" @click="showdata(index)" :key="index">{{index}}{{ todo.text }}</span>
        </li>
    </ul>
    遍历数组
    <div v-for="(value, key, index) in object">
        {{ index }}. {{ key }} : {{ value }}
    </div>

    整数迭代
    <div>
        <span v-for="n in 10">{{ n }}</span>
    </div>
</div>
<script>
var mainapp= new Vue({
        el: '#app',
        data: {
            todos: [
                { text: 'Learn JavaScript' },
                { text: 'Learn Vue.js' },
                { text: 'Build Something Awesome' }
            ],
            object: {
                FirstName: 'John',
                LastName: 'Doe',
                Age: 30
            }

        },
    methods:{
        showdata:function(a){
            console.log(this.$refs.aa[2])
            console.log(a)
        }
    }
    })
</script>
</body>
</html>
